Double world champion Alonso finished third, eclipsed before his 140,000 strong home crowd by Brazilian Massa and the extraordinary Hamilton.
Raikkonen was in third place when he suddenly slowed, allowing Spaniard Alonso past. The Finn nursed his car back to the pits and climbed out.
McLaren: Raikkonen produced a brilliant race with a two-stop strategy.
Narain Karthikeyan finished 17th in Saturday's first qualifying for Sunday's Monaco Grand Prix.
Team by team analysis of Sunday's San Marino Formula One Grand Prix (listed in championship order).\n
Max Verstappen led a soggy Monaco Grand Prix from start to finish on Sunday
Renault's world champion Alonso finished second ahead of Ferrari's Michael Schumacher.
Red Bull's triple world champion Max Verstappen followed up a Saturday sprint win with a statement pole position for Sunday's Austrian Grand Prix, with McLaren's Lando Norris again alongside on the front row.
The Ferrari driver ended world champion Fernando Alonso's run of five successive poles.
Max Verstappen won the season opener as Red Bull registered a dream start with a one-two finish at the Bahrain GP.
Kimi Raikkonen took pole position on an all-Ferrari front row for the Belgian Grand Prix.
McLaren's Lewis Hamilton led the Hungarian Grand Prix from start to finish on Sunday to stretch his championship lead over unhappy team mate Fernando Alonso to seven points.
Finland's Kimi Raikkonen won the French Grand Prix on Sunday, leading Brazilian team mate Felipe Massa in a Ferrari one-two to end McLaren's winning streak.
Lance Armstrong has been voted sports personality of the year, according to a poll published in the Spanish daily
Seven times world champion Lewis Hamilton was seventh for Mercedes and Lance Stroll collected the final point for Aston Martin.
With Sebastian Vettel's fourth successive Formula One title now just a formality, the more intriguing question is whether the Red Bull driver can go on to match a record that has stood for 60 years.
The Scot believes his former McLaren team mate Kimi Raikkonen could yet emerge as Formula One champion this season.\n
Ferrari president Luca di Montezemolo has warned against possible technical 'trickery' as Formula One enters a new and uncertain era.
Fernando Alonso put Renault on pole position for Sunday's Malaysian Grand Prix.
Michael Schumacher is confident he can overtake Fernando Alonso with four races to go in the F1 season.
Germany's Nico Rosberg gave Mercedes their third pole position in succession on Saturday with a front row lockout at the Spanish Formula One Grand Prix.
Seven times world champion Michael Schumacher will start in 14th place after replacing his engine.
Finn Kimi Raikkonen reported back to work as Formula One world champion on Tuesday.
The Ferrari driver's main aim is to prevent Fernando Alonso from chalking up a fifth successive win.
Germany's Nico Rosberg took Mercedes' second successive pole position in qualifying for the Bahrain Formula One Grand Prix on Saturday.
Sahara Force India made a promising start to the 2017 Formula One season with a double points finish through Sergio Perez and Esteban Ocon at the Australian Grand Prix in Melbourne, on Sunday.
Kimi Raikkonen won the Belgian Grand Prix for the third time in a row on Sunday, leading a Ferrari one-two.
A puncture slashed Lewis Hamilton's championship lead over McLaren team mate Fernando Alonso to five points.
McLaren's Lewis Hamilton showed no signs of being slowed by a weekend bout of flu when he set the pace in Friday's first free practice for the European Grand Prix.
McLaren have promised Lewis Hamilton and Fernando Alonso a quicker car for the next race in Germany after losing to Ferrari for the second weekend in a row.
Former world champion Alain Prost believes that McLaren are playing with fire in granting Lewis Hamilton and Fernando Alonso equal status in the team.
McLaren set the pace in Friday's Brazilian Grand Prix practice with Colombian Juan Pablo Montoya the fastest race driver.